using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MTRC.ODMS.Web.SOM.CodeSetup
{
    /// <summary>
    /// Author:Weiyudong
    /// </summary>
    /// 
    public partial class SCDutyShiftList : BasePage_SOM
    {
        #region MenuID

        protected override string MenuID
        {
            get
            {
                return "M140815";
            }
        }

        #endregion

        #region Page Init And Load

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.ChangeLanguage += new ChangeLanguageEventHandler(SetLanguage_Click);
            this.grvData.NeedDataBind += new APJ.Web.UI.WebControls.CommonGridView.NeedDataBindHandler(grvData_NeedDataBind);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // add by dylan 20151030 for u275.1 
                this.grvData.PageSize = this.GridViewPageDefaultSize();
                SetLanguage();
                BindData();
            }
        }
        /// <summary>
        /// bind shift Data list to gridview
        /// </summary>
        private void BindData()
        {
            DataTable dt = MTRC.ODMS.DAL.SOM.CodeSetup.CDShift.GetShiftList( this.txtShift.Text.Trim(), this.chkVoid.Checked,this.txtDescription.Text.Trim());
            this.grvData.DataSource = dt.DefaultView;
            this.grvData.DataBind();
        }

        #endregion

        #region SetLanguage

        void SetLanguage_Click(object sender, EventArgs e)
        {
            SetLanguage();
            BindData();
        }
        /// <summary>
        /// for multi language
        /// </summary>
        private void SetLanguage()
        {
            //this.lblCodeSetupTitle.Text = this.GetLabel("SOM_SCDutyShiftListTitle");
            this.lblShift.Text = this.GetLabel("SOM_ShiftCode", true);
            this.lblDescription.Text = this.GetLabel("COM_Description", true);
            this.chkVoid.Text = this.GetLabel("SOM_Voided");
            this.btnSearch.Text = this.GetLabel("COM_Search");
            this.btnAddNew.Text = this.GetLabel("SOM_AddNewAssetLoanItem");
            this.lblDisplay.Text = this.GetLabel("COM_Show", true);
        }
        #endregion

        #region Event
        /// <summary>
        /// search onclick ,retrieve the data by criteria
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }
        /// <summary>
        /// new IsolateReason record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddNew_Click(object sender, EventArgs e)
        {
            this.Response.Redirect("SCDutyShiftEntry.aspx");
        }
        /// <summary>
        /// for multi page 
        /// </summary>
        protected void grvData_NeedDataBind()
        {
            BindData();
        }
        /// <summary>
        /// for edit function
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grvData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToUpper() == ("edit").ToUpper())
            {
                this.Response.Redirect("SCDutyShiftEntry.aspx?shiftID=" + e.CommandArgument.ToString());
            }
        }
        #endregion

        
    }
}
